import {GET_RECOMMEND,GET_DETAIL,ADD_BOOK,DELE_BOOK} from './actionType'
import axios from 'axios'
export const getRecommend=(a)=>{
    return async dispatch=>{
        const res=await  axios.get(`https://wxapi.chuangbie.com/wap/index/${a}.html`)
        dispatch({ type: GET_RECOMMEND,payload: res.data.data})
    }
}
export const getDetail=(Id)=>{
    return async dispatch=>{
        const res=await  axios.get(`https://wxapi.chuangbie.com/wap/book/bookInfo.html?book_id=${Id}`)
        dispatch({ type: GET_DETAIL,payload: res.data.data})
    }
}

export const addBook=(data)=>{
    return async dispatch=>{
        dispatch({ type: ADD_BOOK,payload: data})
    }
}

export const deleBook=(index)=>{
    return async dispatch=>{
        dispatch({ type: DELE_BOOK,payload: index})
    }
}
